<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
<title>动态简单模式</title>
<link href="/kissy/build/css/dpl/base.css" rel="stylesheet"/>
<link href="../assets/default.css" rel="stylesheet"/>

</head>
<body>
<h1>全新产生新节点</h1>
<div style="margin:10px auto; width:800px;text-align: center" id="newNew">
    <h2>
        dynamic
    </h2>
</div>
<script src="/kissy/build/seed.js"></script>
<script src="/kissy/src/package.js"></script>
<script>
    KISSY.use("combobox", function (S, ComboBox) {

        /*
         remote dataSource
         */
        (function () {

            var basicComboBox = new ComboBox({
                render:"#newNew",
                hasTrigger:false,
                dataSource:new ComboBox.RemoteDataSource({
                    xhrCfg:{
                        url:'./interface2.jss',
                        dataType:'json'
                    },
                    paramName:"start",
                    parse:function (inputVal, d) {
                        return d.result;
                    }
                }),
                maxItemCount:5,
                format:function (query, data) {
                    var ret = [];
                    for (var i = 0; i < data.length; i++) {
                        ret[i] = {
                            content:(data[i] + "")
                                    .replace(new RegExp(S.escapeRegExp(query), "g"),
                                    "<b>$&</b>"),
                            disabled:(i % 2 ? true : false)
                        };
                    }
                    return ret;
                }
            });
            basicComboBox.render();

            basicComboBox.on("click", function (e) {
                var item = e.target;
                S.log(item.get("value") + "\n" + item.get("content") +
                        "\n" + item.get('textContent'));
            });
        })();
    });
</script>
</body>
</html>